package com.taxigang.client.uibinder.fbpage;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.taxigang.client.TaxiGangHandler;
import com.taxigang.client.micro.TaxiGangCreator;
import com.taxigang.client.micro.TaxiGangText;
import com.taxigang.shared.AmbassadorResponseInfo;

public class Ambassador extends Composite  {

	private static AmbassadorUiBinder uiBinder = GWT.create(AmbassadorUiBinder.class);

	interface AmbassadorUiBinder extends UiBinder<Widget, Ambassador> {
	}

	//	@UiField
	//	DivElement fbLoginButton;


	@UiField
	DivElement fbShareButton;
	@UiField
	Panel welcomePanelLiked;
	@UiField
	Panel welcomePanelNotLiked;
	@UiField
	Label ambassadorText1;
	@UiField
	Label ambassadorText2;
	@UiField
	Label ambassadorText3;
	@UiField
	Label ambassadorText4;
	@UiField
	Label ambassadorText5;
	@UiField
	Label ambassadorText6;
	@UiField
	Label ambassadorText7;
	@UiField
	Button gotoTaxigang;


	@UiField
	Label ambassadorTextNotLiked;

	Label nameLabel = new Label("Name:");
	TextBox nameBox = new TextBox();
	Label emailLabel = new Label("Email:");
	TextBox emailBox = new TextBox();
	Label phoneLabel = new Label("Handy:");
	TextBox phoneBox = new TextBox();
	Label birthdayLabel = new Label("Geburtstag:");
	TextBox birthdayBox = new TextBox();
	Label placeLabel = new Label("Wohnort:");
	TextBox placeBox = new TextBox();
	Label doyouhavetimeLabel = new Label("Hast du am Samstag 5. Mai um 14:00 Zeit?");
	
	Grid grid = new Grid(7, 2);

	@UiField
	Label thankYouLabel;

	//FlowPanel  hp = new FlowPanel ();
	Button button = new Button("Submit");

	public Ambassador(String pageId, boolean liked) {
		initWidget(uiBinder.createAndBindUi(this));
		//pageId="174406889328525";
		fbShareButton.setAttribute("data-href", "www.facebook.com/"+pageId);
		//		fbLoginButton.setInnerHTML("<fb:login-button/>");

		welcomePanelLiked.setVisible(liked);
		welcomePanelNotLiked.setVisible(!liked);

		gotoTaxigang.setText(TaxiGangText.taxiGangConstants.startTaxigang());
		gotoTaxigang.setVisible(liked);

		ambassadorText1.setText(TaxiGangCreator.taxiGangConstants.ambassadorText1());
		ambassadorText2.setText(TaxiGangCreator.taxiGangConstants.ambassadorText2());
		ambassadorText3.setText(TaxiGangCreator.taxiGangConstants.ambassadorText3());
		ambassadorText4.setText(TaxiGangCreator.taxiGangConstants.ambassadorText4());
		ambassadorText5.setText(TaxiGangCreator.taxiGangConstants.ambassadorText5());
		ambassadorText6.setText(TaxiGangCreator.taxiGangConstants.ambassadorText6());
		ambassadorText7.setText(TaxiGangCreator.taxiGangConstants.ambassadorText7());

		ambassadorTextNotLiked.setText("Erst mal Like klicken um fortzufahren!");
		
		grid.setWidget(0, 0, nameLabel);
		grid.setWidget(0, 1, nameBox);
		grid.setWidget(1, 0, emailLabel);
		grid.setWidget(1, 1, emailBox);
		grid.setWidget(2, 0, phoneLabel);
		grid.setWidget(2, 1, phoneBox);
		grid.setWidget(3, 0, phoneLabel);
		grid.setWidget(3, 1, phoneBox);
		grid.setWidget(4, 0, placeLabel);
		grid.setWidget(4, 1, placeBox);
		
//		RadioButton yesRadio = new RadioButton("group","Ja");
//		
//		RadioButton noRadio = new RadioButton("group","Nein");
//		hp.add(yesRadio);
//		hp.add(noRadio);

		//grid.setWidget(5, 0, doyouhavetimeLabel);
		//grid.setWidget(5, 1, hp);

		grid.setWidget(6, 1, button);

		welcomePanelLiked.add(grid);
		welcomePanelLiked.add(thankYouLabel);
		thankYouLabel.setText(TaxiGangCreator.taxiGangConstants.ambassadorThankyou());
		thankYouLabel.setVisible(false);
		//welcomePanelLiked.add(hp);

		button.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				AmbassadorResponseInfo info = new AmbassadorResponseInfo();
				info.name = nameBox.getText();
				info.email = emailBox.getText();
				info.handy = phoneBox.getText();
				info.place = placeBox.getText();
				TaxiGangHandler.getInstance().sendAmbassadorResponse(info);

				thankYouLabel.setVisible(true);
				grid.setVisible(false);

			}
		});
		
	}


}
